<?
    require_once("config.php");
    require_once("objects/image_table.php");
    require_once("objects/image_viewer.php");
    
    $menu = new Menu("Image Viewer");
    $menu->AddItem(new MenuItem("Back to Listing","listing.php?action=view&id=$_GET[id]",AuthConstants::ALL_LOGGED_IN));
    
    Functions::PrintHeader("Image Viewer");
    if (!$_GET['id']) {
        ErrorMessage::Show("No Listing Specified","No listing was specified.  You must access this page from the page of the listing you were viewing.");
    }
    else {
        MenuManager::AddMenu("Image Viewer",$menu);
        
        if (is_numeric($_GET['index'])) {
            // then we show that image
            echo new ImageViewer($_GET['id'],$_GET['index']);
        }
        else {
            // then we need to display a grid of images -- easy enough
            echo new ImageTable($_GET['id']);
        }
    }   
    Functions::PrintFooter();
?>